<template>
    <div class="photoinfo">
        <h3>{{photoinfo.title}}</h3>
        <p class="subtitle">
            <span>发表时间:{{photoinfo.add_time | dataFormat}}</span>
            <span>评论次数:{{photoinfo.click}}</span>
        </p>
        <hr>
      
      <!-- 缩略图 -->
      <!-- 缩略图区域 -->
        <!-- <div class="thumbs">
          <img class="preview-img" v-for="(item, index) in list" :src="item.src" height="100" @click="$preview.open(index, list)" :key="item.src">
        </div> -->
         <div id="thumbs">
            <vue-preview  :slides="list" @close="handleClose"></vue-preview>
        </div>
        
          <!-- 图片内容区域 -->
        <div class="content" v-html="photoinfo.content">
        </div>
        <!--放置一个现成的子组件  -->
        <cmt-box :id="id"></cmt-box>
    </div>
</template>
<script>
import { getPhotoInfo, getThumImages } from "@/api";
import comment from "@/components/subcomponents/comment.vue";

export default {
  data() {
    return {
      id: this.$route.params.id,
      photoinfo: {},
      list: [] //缩略图数组
    };
  },
  created() {
    getPhotoInfo(this.id).then(res => {
      //console.log(res, 777444);
      if (res.data.status == 0) {
        this.photoinfo = res.data.message[0];
        // console.log(this.photoinfo,777444);
      }
    });

    /* 缩略图 */
    getThumImages(this.id).then(res => {
      console.log(res);
      if (res.data.status == 0) {
        res.data.message.forEach(item => {
          item.w = 300;
          item.h = 300;
          item.msrc = item.src;
        });
        this.list = res.data.message;
        console.log(this.list, 888);
      }
    });
  },
  methods: {
    handleClose() {
      console.log("close event");
    }
  },
  components: {
    "cmt-box": comment
  }
};
</script>
<style lang="less" scoped>
.photoinfo {
  padding: 3px;
  h3 {
    color: #26a2ff;
    font-size: 15px;
    text-align: center;
    margin: 15px 0;
  }
  .subtitle {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
  }
  .content {
    font-size: 13px;
    line-height: 30px;
  }     

}
</style>
